<template>
  <div>
    <div class="mod-header">
      <span class="mod-tit">{{gettit}}</span>
      <!-- 查询 -->
      <el-form class="mod-disinb" :inline="true" :model="dataForm"></el-form>
    </div>
    <div class="mod-config">
      <!-- 查询 -->
      <el-form class="mod-disinb" :inline="true" :model="dataForm"></el-form>
      <!-- 表格 -->
      <el-table
        :data="dataList"
        border
        ref="listTable"
        class="columns-fit"
        :class="dataListLoading ? null : 'visible'"
        @selection-change="selectionChangeHandle"
        style="width: 100%;"
      >
        <el-table-column
          type="selection"
          header-align="center"
          :width="colWidthList[0]"
          align="center"
        ></el-table-column>
        <el-table-column header-align="center" align="center" width="200" label="操作">
          <template slot-scope="scope">
            <el-button type></el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        background
        @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
        :current-page="pageIndex"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        :total="totalPage"
        layout="total,  prev, pager, next, sizes,jumper"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      dataForm: {},
      dataList: [],
      colWidthList: [],
      dataListLoading: false,
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0
    };
  },
  activated() {},
  watch: {
    "$route.path": function(newVal, oldVal) {
      if (newVal) {
      }
    }
  },
  computed: {
    gettit() {
      return this.$route.meta.title;
    }
  },
  methods: {
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true;
      this.$http({
        url: this.$http.adornUrl(""),
        method: "get",
        params: this.$http.adornParams({
          page: this.pageIndex,
          limit: this.pageSize
        })
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.dataList = data.page.list;
          this.totalPage = data.page.totalCount;
        } else {
          this.dataList = [];
          this.totalPage = 0;
        }
        this.$nextTick(() => {
          setTimeout(() => {
            this.colWidthList = this.$adjustColumnWidth(
              this.$refs["listTable"].$el
            );
            this.dataListLoading = false;
          });
        });
      });
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val;
      this.pageIndex = 1;
      this.getDataList();
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val;
      this.getDataList();
    },
    // 多选
    selectionChangeHandle(val) {
      this.dataListSelections = val;
    }
  }
};
</script>

<style>
</style>